package psd.model.Prolog.Converters;

import org.eclipse.jdt.core.dom.Initializer;

import psd.model.IConverter;
import psd.model.Prolog.FactGenerationToolbox;
import psd.model.Prolog.PrologConverter;


public class PrologInitializerConverter extends PrologConverter
implements IConverter<Initializer>{
	
	String INITIALIZER_NAME = "<clinit>";

	public PrologInitializerConverter(FactGenerationToolbox toolbox) {
		super(toolbox);
	}

	@Override
	public boolean convert(Initializer node) {
		 String id = idResolver.getID(node);
	        String parentId = getParentId(node);
	        String name = quote(INITIALIZER_NAME);
	        String param = PrologCommon.getEmptyList();
	        String type = "null";
	        String exceptions = PrologCommon.getEmptyList();
	        String body = idResolver.getID(node.getBody());
	        String args[] = {
	            id, parentId, name, param, type, exceptions, body, this.getFilePath(node), this.getLineNumber(node)
	        };
	        writer.writeFact("methodDefT", args);
	        //createAnnotationFact(node, id);
	        writer.writeFact("slT", new String[] {
	            idResolver.getID(node), Integer.toString(node.getStartPosition()), Integer.toString(node.getLength()), this.getFilePath(node), this.getLineNumber(node)
	        });
	        writeModifiers(node, node.getModifiers());
	        return true;
	}

}
